package com.interview.javabase.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author: zsg
 * @description:
 * @date: 2019/6/29 10:25
 * @modified:
 */
public class Demo3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println("当前线程为: "+ Thread.currentThread().getName()+ i);
                    if (i == 5){
                        Thread.yield();
                    }
                }
            }
        };

        Thread thread = new Thread(runnable,"A");
        Thread thread1 = new Thread(runnable,"B");
        thread.start();
        thread1.start();
    }
}